package cbfg.popup.demo

import android.os.Bundle
import android.view.View
import android.widget.ArrayAdapter
import android.widget.Toast
import cbfg.popup.BDialogFragment
import kotlinx.android.synthetic.main.popup_options.view.*

/**
 * @author:  Tom Hawk
 * 添加时间: 2020/9/9 15:14
 * 功能描述:
 */
class OptionsDF : BDialogFragment() {
    private val options = arrayListOf("aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh")

    init {
        mLayoutRes = R.layout.popup_options
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        val lvOptions = view.lvOptions
        lvOptions.adapter = ArrayAdapter<String>(
            view.context,
            android.R.layout.simple_list_item_1,
            options
        )
        lvOptions.setOnItemClickListener { _, _, i, _ ->
            Toast.makeText(view.context, "click ${options[i]}", Toast.LENGTH_SHORT).show()
            dismiss()
        }
    }
}